#include <iostream>
#include <string>

using namespace std;

void printString(const string &str)
{
    cout << str << endl;
}

void test01()
{
    // char st[5] = "hello";
    string str("Hello");
    cout << "str length: " << str.length() << " " << str.size() << endl;

    /*  
    //test string public function
    char *c = nullptr;
    c = str.data();   //
    const char *c1 = nullptr;
    c1 = str.c_str();  // 
*/

    printString(str);
    cout << str.size() << " " << str.length();
    int n_ofsize = sizeof(str);
    int n_size = str.size();
    int n_capacity = str.capacity();
    cout << "sizeof: " << n_ofsize << endl;
    cout << "size:" << n_size << "  capacity: " << n_capacity << endl;

    string str1(str);
    printString(str1);
    string str2;
    printString(str2);
    string str3(5, 'p');
    printString(str3);

    string str4;
    str4 = 'u';
    printString(str4);
    string str5 = "hello world";
    printString(str5);

    string str6(str);
    str6 += ' ';
    str6 += str5;
    str6 += "!!!";
    // str6.assign(str);
    str6.append(" How ");
    str6.append(str1, 1, 2);
    str6.insert(6, str3);
    str6.erase(6, 5);
    printString(str6);

    int pos = str6.find("or");
    string str7 = str6.substr(0, pos);
    printString(str7);

    int com = str.compare(str1);
    cout << com << endl;

    int arr[10] = {0};
    for (auto n : arr)
    {
        std::cout << n;
    }
}

int main()
{
    cout << __FILE__ << __LINE__ << endl;
    test01();
    return 1;
}
